﻿using System;
using System.Runtime.Serialization;

namespace TeamTasker.Contracts
{
    [DataContract]
    public class TeamMember
    {
        [DataMember]
        public long TeamID { get; set; }

        [DataMember]
        public long UserID { get; set; }

        private User user;

        [DataMember]
        public User User
        {
            get { return user; }
            set
            {
                user = value;
                UserID = (user != null ? user.ID : 0);
            }
        }

        [DataMember]
        public bool IsOwner { get; set; }

        public TeamMember()
            : this(0, 0, false)
        {
        }

        public TeamMember(long userID, bool isOwner)
            : this(0, userID, isOwner)
        {
        }

        public TeamMember(long teamID, long userID, bool isOwner)
        {
            TeamID = teamID;
            UserID = userID;
            IsOwner = isOwner;
        }
    }
}
